package com.mtbu.bean.base;
import java.util.*;
import java.text.SimpleDateFormat;
import org.json.JSONObject;
import my.json.core.JsonAble;
public abstract class StepBase implements JsonAble {
    private Map<String, Object> dirtyProperties = new HashMap<String, Object>();
    //
    private int id = 0;
    //0直接步骤 1修改步骤
    private int type = 0;
    //
    private int status = 0;
    //
    private Date createTime = null;
    //
    private Date updateTime = null;
    //对应操作的执行bean的名字
    private String beanName = "";
    //
    private int nextStepId = 0;
    //
    private int preStepId = 0;
    //
    private int projectId = 0;
    //
    private String name = "";
    public int getId(){
        return this.id;
    }
    public void setId(int id){
        this.id = id;
    }
    public int getType(){
        return this.type;
    }
    public void setType(int type){
        this.type = type;
        dirtyProperties.put("type", type);
    }
    public int getStatus(){
        return this.status;
    }
    public void setStatus(int status){
        this.status = status;
        dirtyProperties.put("status", status);
    }
    public Date getCreateTime(){
        return this.createTime;
    }
    public String getCreateTime_ToDateString(){
        if(createTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(this.createTime);
    }
    public String getCreateTime_ToTimeString(){
        if(createTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(this.createTime);
    }
    public String getCreateTime_ToDateTimeString(){
        if(createTime==null)   return "";
        SimpleDateFormat   formatter   =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(this.createTime);
    }
    public void setCreateTime(Date createTime){
        this.createTime = createTime;
        dirtyProperties.put("createTime", createTime);
    }
    public Date getUpdateTime(){
        return this.updateTime;
    }
    public String getUpdateTime_ToDateString(){
        if(updateTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(this.updateTime);
    }
    public String getUpdateTime_ToTimeString(){
        if(updateTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(this.updateTime);
    }
    public String getUpdateTime_ToDateTimeString(){
        if(updateTime==null)   return "";
        SimpleDateFormat   formatter   =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(this.updateTime);
    }
    public void setUpdateTime(Date updateTime){
        this.updateTime = updateTime;
        dirtyProperties.put("updateTime", updateTime);
    }
    public String getBeanName(){
        return this.beanName;
    }
    public void setBeanName(String beanName){
        this.beanName = beanName;
        dirtyProperties.put("beanName", beanName);
    }
    public int getNextStepId(){
        return this.nextStepId;
    }
    public void setNextStepId(int nextStepId){
        this.nextStepId = nextStepId;
        dirtyProperties.put("nextStepId", nextStepId);
    }
    public int getPreStepId(){
        return this.preStepId;
    }
    public void setPreStepId(int preStepId){
        this.preStepId = preStepId;
        dirtyProperties.put("preStepId", preStepId);
    }
    public int getProjectId(){
        return this.projectId;
    }
    public void setProjectId(int projectId){
        this.projectId = projectId;
        dirtyProperties.put("projectId", projectId);
    }
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name = name;
        dirtyProperties.put("name", name);
    }
    public Map<String, Object> getDirtyProperties() {
        return this.dirtyProperties;
    }
    public JSONObject toJSON() throws Exception {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        json.put("id", this.getId());
        json.put("type", this.getType());
        json.put("status", this.getStatus());
        if(createTime!=null){
            json.put("createTime",formatter.format(this.getCreateTime()));
        }
        if(updateTime!=null){
            json.put("updateTime",formatter.format(this.getUpdateTime()));
        }
        if(beanName!=null){
           json.put("beanName",this.getBeanName());
        }
        json.put("nextStepId", this.getNextStepId());
        json.put("preStepId", this.getPreStepId());
        json.put("projectId", this.getProjectId());
        if(name!=null){
           json.put("name",this.getName());
        }
        return json;
    }
    public void fromJSON(JSONObject json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            if(json.get("id") != null){
                this.setId(Integer.parseInt(json.get("id")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("type") != null){
                this.setType(Integer.parseInt(json.get("type")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("status") != null){
                this.setStatus(Integer.parseInt(json.get("status")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("createTime") != null){
                this.setCreateTime(formatter.parse(json.get("createTime")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("updateTime") != null){
                this.setUpdateTime(formatter.parse(json.get("updateTime")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("beanName") != null){
                this.setBeanName(json.get("beanName")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("nextStepId") != null){
                this.setNextStepId(Integer.parseInt(json.get("nextStepId")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("preStepId") != null){
                this.setPreStepId(Integer.parseInt(json.get("preStepId")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("projectId") != null){
                this.setProjectId(Integer.parseInt(json.get("projectId")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("name") != null){
                this.setName(json.get("name")+"");
            }
        }catch(Exception ex){
        }
    }
    public void fromMap(Map<String, String> json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            if(json.containsKey("id".toLowerCase())){
                this.setId(Integer.parseInt(json.get("id".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("type".toLowerCase())){
                this.setType(Integer.parseInt(json.get("type".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("status".toLowerCase())){
                this.setStatus(Integer.parseInt(json.get("status".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("createTime".toLowerCase())){
                this.setCreateTime(formatter.parse(json.get("createTime".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("updateTime".toLowerCase())){
                this.setUpdateTime(formatter.parse(json.get("updateTime".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("beanName".toLowerCase())){
                this.setBeanName(json.get("beanName".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("nextStepId".toLowerCase())){
                this.setNextStepId(Integer.parseInt(json.get("nextStepId".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("preStepId".toLowerCase())){
                this.setPreStepId(Integer.parseInt(json.get("preStepId".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("projectId".toLowerCase())){
                this.setProjectId(Integer.parseInt(json.get("projectId".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("name".toLowerCase())){
                this.setName(json.get("name".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
    }
}
